<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2017/10/13
 * Time: 9:24
 */
namespace  Admin\Model;
use Think\Model;

class ShopModel extends Model{
    //获取店铺详情的
    protected function _before_insert(&$data, $option)
    {
        if(isset($_FILES['license']) && $_FILES['license']['error'] == 0)
        {

            $ret = uploadOne('shop_logo', 'shop');
            if($ret['ok'] == 1)
            {
                $data['license'] = $ret['images'][0];
            }
            else
            {
                $this->error = $ret['error'];
                return FALSE;
            }
        }
        if(isset($_FILES['permit']) && $_FILES['permit']['error'] == 0)
        {
            $ret = uploadOne('permit', 'shop');
            if($ret['ok'] == 1)
            {
                $data['permit'] = $ret['images'][0];
            }
            else
            {
                $this->error = $ret['error'];
                return FALSE;
            }
        }
        if(isset($_FILES['ID_photo_front']) && $_FILES['ID_photo_front']['error'] == 0)
        {
            $ret = uploadOne('ID_photo_front', 'shop');
            if($ret['ok'] == 1)
            {
                $data['ID_photo_front'] = $ret['images'][0];
            }
            else
            {
                $this->error = $ret['error'];
                return FALSE;
            }
        }
        if(isset($_FILES['ID_photo_back']) && $_FILES['ID_photo_back']['error'] == 0)
        {
            $ret = uploadOne('ID_photo_back', 'shop');
            if($ret['ok'] == 1)
            {
                $data['ID_photo_back'] = $ret['images'][0];
            }
            else
            {
                $this->error = $ret['error'];
                return FALSE;
            }
        }
        if(isset($_FILES['Shop_photo1']) && $_FILES['Shop_photo1']['error'] == 0)
        {
            $ret = uploadOne('Shop_photo1', 'shop');
            if($ret['ok'] == 1)
            {
                $data['Shop_photo1'] = $ret['images'][0];
            }
            else
            {
                $this->error = $ret['error'];
                return FALSE;
            }
        }
        if(isset($_FILES['Shop_photo2']) && $_FILES['Shop_photo2']['error'] == 0)
        {
            $ret = uploadOne('Shop_photo2', 'shop');
            if($ret['ok'] == 1)
            {
                $data['Shop_photo2'] = $ret['images'][0];
            }
            else
            {
                $this->error = $ret['error'];
                return FALSE;
            }
        }
        if(isset($_FILES['Front_view1']) && $_FILES['Front_view1']['error'] == 0)
        {
            $ret = uploadOne('Front_view1', 'shop');
            if($ret['ok'] == 1)
            {
                $data['Front_view1'] = $ret['images'][0];
            }
            else
            {
                $this->error = $ret['error'];
                return FALSE;
            }
        }
        if(isset($_FILES['Front_view2']) && $_FILES['Front_view1']['error'] == 0)
        {
            $ret = uploadOne('Front_view2', 'shop');
            if($ret['ok'] == 1)
            {
                $data['Front_view2'] = $ret['images'][0];
            }
            else
            {
                $this->error = $ret['error'];
                return FALSE;
            }
        }

    }
    //获取拼单详情

}